<?php

namespace app\admin\model;

use think\Model;


class TeacherDetail extends Model
{



    private $c_sql = "CREATE TABLE `fa_teacher_detail` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `info_id` int(10) DEFAULT NULL COMMENT '身份id',
  `club_one_id` int(10) DEFAULT NULL COMMENT '社团id',
  `club_two_id` int(10) DEFAULT NULL COMMENT '子社团id',
  `hourly_rate` decimal(11,1) DEFAULT NULL COMMENT '课时费用',
  `appointment_time_week` varchar(255) DEFAULT '' COMMENT '可约时间（周）',
  `appointment_time` varchar(255) DEFAULT '' COMMENT '可约时间（时）',
  `teacher_certification` text COMMENT '教师资格证',
  `diploma` text COMMENT '毕业证书',
  `occupational_qualifications` text COMMENT '获奖证书',
  `course_outline` text COMMENT '课程大纲',
  `teaching_objectives` text COMMENT '教学目标',
  `knowledge_requirements` text COMMENT '预备知识要求',
  `imgs` text COMMENT '形象照',
  `addtime` datetime DEFAULT NULL COMMENT '添加时间',
  `sort` int(10) DEFAULT NULL COMMENT '排序',
  `tag` varchar(100) DEFAULT NULL COMMENT '标签',
  `score` decimal(6,1) DEFAULT '10.0' COMMENT '评分',
  `user_score` varchar(255) DEFAULT '' COMMENT '用户评分',
  `people` int(10) DEFAULT '0' COMMENT '人数',
  `personal_resume` text COMMENT '个人简历',
  `professional_skill` text COMMENT '专业技能证书',
  `health_certificate` text COMMENT '健康证',
  `identity_card_img` varchar(500) DEFAULT NULL COMMENT '身份证复印件',
  `no_crime` text COMMENT '无犯罪证明',
  `area` varchar(255) DEFAULT '' COMMENT '区域',
  `is_all` varchar(255) DEFAULT '否' COMMENT '是否上传完整',
  `educational_back` text COMMENT '教育背景',
  `work_experience` text COMMENT '工作经历',
  `certificate_reward` text COMMENT '证书奖励',
  `self_assessment` text COMMENT '自我评价',
  `tag_me` varchar(255) DEFAULT '' COMMENT '自评标签',
  `jxjh` text COMMENT '教学计划',
  `work_time` varchar(100) DEFAULT '' COMMENT '工作经营时长',
  `education_background` varchar(255) DEFAULT '' COMMENT '最高学历',
  `is_premium` int(10) DEFAULT '0' COMMENT '是否精品 0否 1是',
  `word_file` varchar(255) DEFAULT '' COMMENT '文档地址',
  `order_num` int(10) DEFAULT '0' COMMENT '订单数量',
  PRIMARY KEY (`id`),
  KEY `info_id` (`info_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8mb4 COMMENT='教师身份表';";

    // 表名
    protected $name = 'teacher_detail';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'work_time_text'
    ];
    

    




    public function getWorkTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['work_time']) ? $data['work_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    protected function setWorkTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }



    public function clubDtl(){
        return $this->hasOne(ClubDtl::class,'id','club_two_id', [], 'LEFT')->setEagerlyType(0);
    }

    public function club(){
        return $this->hasOne(Club::class,'id','club_one_id', [], 'LEFT')->setEagerlyType(0);
    }

    public function clubDtlS(){
        return $this->hasOne(ClubDtl::class,'id','club_two_id', [], 'LEFT')->field('id,name,stage,grade,img_url');
    }

    public function clubs(){
        return $this->hasOne(Club::class,'id','club_one_id', [], 'LEFT');
    }

    public function identity(){
        return $this->hasOne(IdentityInfo::class,'id','info_id', [], 'LEFT')->with('user');
    }
}
